#include <stdio.h>
int main() {
    int i = 0;
    int s = 8;
    int arr[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
    int n = sizeof(arr) / sizeof(arr[0]);
    int right = n - 1;
    int left = 0;
    while (left <= right)
    {
        int mid = left + (right - left) / 2;//防止溢出
        if (arr[mid] < s)
        {
            left = mid + 1;
        }
        else if (arr[mid] > s)
        {
            right = mid - 1;
        }
        else
        {
            printf("下标是%d\n", mid);
            break;
        }

    }
    if (left > right)
    {
        printf("没有找到");
    }

    return 0;
}
